//
//  VisitorViewController.swift
//  WeiBlog
//
//  Created by xiang on 15/10/15.
//  Copyright © 2015年 xiang. All rights reserved.
//

import UIKit

class VisitorViewController: UITableViewController {

    lazy var visitorView:VisitorView = {
        
        let vi = VisitorView()
        
        vi.delegate = self
        
        return vi
        }()


    override func loadView() {
        
        /**
        注意这是一个基类,继承自UITableViewController,所以默认情况下view是tableView
        下面在view = VisitorView就是在替换view
        */
        //判断用户是否登录
        let logSign = UserAccountViewModel.sharedUserAccountViewModel.isLogin
        
        logSign ? super.loadView(): (view = visitorView)
       
    }

}

// MARK:实现代理方法
extension VisitorViewController:VisitorViewDelegate
{
    //登录
    func loginToModal() {
        
        let vc = LoginViewController()
        
        let navi = UINavigationController(rootViewController: vc)

        presentViewController(navi, animated: true, completion: nil)
    }
    
    //注册
    func registerToModal() {
        //
        loginToModal()
    }
    
}